package test;

import java.awt.Color;
import java.util.LinkedList;

import alice.tuprolog.MalformedGoalException;
import alice.tuprolog.NoSolutionException;
import alice.tuprolog.Prolog;
import alice.tuprolog.SolveInfo;
import alice.tuprolog.Struct;
import alice.tuprolog.UnknownVarException;

public class Chuck {

	Prolog engine = new Prolog();
	LinkedList<Polygon> polygonList = new LinkedList<Polygon>();

	public Chuck() throws Exception{
		SolveInfo info = engine.solve("polygon(Name,Vertices,Color,Texture,Layer).");
		while (info.isSuccess()){
			Struct s = (Struct) info.getTerm("Vertices");
			LinkedList<Coordinate> coordList = Test.listVertices(s);
			Color c = Test.stringToColor(Test.colorStrip(info.getTerm("Color").toString()));
			
			polygonList.add(new Polygon(info.getTerm("Name").toString(), coordList,c));
			
			
			if (engine.hasOpenAlternatives())
				info = engine.solveNext();
			else
				break;
		}
	}
	
}
